package models

import (
	"login/common"
	"time"
)

// Token 模型定义
type Token struct {
	ID         uint      `gorm:"primaryKey"`
	Token      string    `gorm:"uniqueIndex;not null"`
	Expiration time.Time `gorm:"not null"`
}

func SaveToken(token string, expiration time.Time) error {
	db := common.DB
	newToken := Token{
		Token:      token,
		Expiration: expiration,
	}

	// 保存到数据库
	result := db.Create(&newToken)
	return result.Error // 返回可能的错误
}
